package oop.core.view.listeners;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import oop.core.med.TransactionMediator;

/**
 * Invoked when a user clicks on an item to sell in the sales panel
 * of the MercantInteractionmMenu.
 * @author Alex
 *
 */

public class SellingInventoryListener implements MouseListener {

	private TransactionMediator transactionMediator;
	
	public SellingInventoryListener(TransactionMediator transactionMediator)
	{
		this.transactionMediator = transactionMediator;
	}
	
	@Override
	public void mouseClicked(MouseEvent e) {
		int x = e.getX();
		int y = e.getY();
		InventoryIndexCalculator calc = new InventoryIndexCalculator();
		int code = calc.getCode(x, y);
		if(code == -1)
			return;
		transactionMediator.sell(code);
	}

	@Override
	public void mouseEntered(MouseEvent e) {
	}

	@Override
	public void mouseExited(MouseEvent e) {
		transactionMediator.clearTransaction();
	}

	@Override
	public void mousePressed(MouseEvent e) {
	}

	@Override
	public void mouseReleased(MouseEvent e) {
	}

}
